/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ManagedBeans;

import Beans.Poke;
import dao.PokeDao;
import java.io.Serializable;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;

/**

 @author Marie-Claude
 */
@ManagedBean(name = "pokeManager")
@RequestScoped
public class PokeManager implements Serializable {

  private List<Poke> lstPokes;
  @ManagedProperty(value = "#{userManager}")
  private UserManager mbUser;

  /**
   Creates a new instance of PokeManager
   */
  public PokeManager() {
  }

  public List<Poke> getLstPokes() {
    return lstPokes;
  }

  public void setLstPokes(List<Poke> lstPokes) {
    this.lstPokes = lstPokes;
  }

  public UserManager getMbUser() {
    return mbUser;
  }

  public void setMbUser(UserManager mbUser) {
    this.mbUser = mbUser;
  }

  @PostConstruct
  public void init() {
    if (mbUser.getUser().getUserID() >= 1) {
      lstPokes = PokeDao.getAllByUserId(mbUser.getUser().getUserID());
    }

  }

  public String dismiss() {
    PokeDao.deleteWinks(mbUser.getUser().getUserID());
    lstPokes = PokeDao.getAllByUserId(mbUser.getUser().getUserID());
    return null;
  }

}
